﻿// See https://aka.ms/new-console-template for more information

using System;

namespace PrimeNumbers
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("你好！我是施恩泽");
            Console.Write("请输入上限: ");
            int upperLimit = int.Parse(Console.ReadLine());

            Console.Write("请输入下限: ");
            int lowerLimit = int.Parse(Console.ReadLine());

            PrintPrimes(lowerLimit, upperLimit);
        }

        static void PrintPrimes(int lowerLimit, int upperLimit)
        {
            int count = 0;
            for (int i = lowerLimit; i <= upperLimit; i++)
            {
                if (IsPrime(i))
                {
                    Console.Write(i + "\t");
                    count++;
                    if (count % 10 == 0)
                    {
                        Console.WriteLine();
                    }
                }
            }
            if (count % 10 != 0)
            {
                Console.WriteLine();
            }
        }

        static bool IsPrime(int number)
        {
            if (number <= 1) return false;
            for (int i = 2; i <= Math.Sqrt(number); i++)
            {
                if (number % i == 0) return false;
            }
            return true;
        }
    }
}